$(function () {
    let id = localStorage.getItem("facilitiesId");
    getByFacilitiesId(id);
});

function getByFacilitiesId(id) {
    let data = myAjax('/getByFacilitiesId', 'get', {id: id});
    data = data.list;
    console.log(data);
    $("#shangyitiao").html('<span>上一条：无</span>');
    $("#xiayitiao").html('<span>下一条：无</span>');
    for (let i = 0; i < data.length; i++) {
        //根据数据的id进行判断 进行不同操作
        if (data[i].id < id) {
            $("#shangyitiao").html('<span onclick="getByFacilitiesId(' + data[i].id + ')">上一条：' + data[i].title + '</span>');
        } else if (data[i].id == id) {
            console.log("----------------");
            setFacilitiesData(data[i]);
        } else {
            $("#xiayitiao").html('<span onclick="getByFacilitiesId(' + data[i].id + ')">下一条：' + data[i].title + '</span>');
        }
    }
}

function setFacilitiesData(data) {
    $("#author").html(data.author);
    $("#title").html(data.title);
    $("#dabiaoti").html(data.title);
    $("#releaseTime").html(data.releaseTime);
    $("#facilitiesContent").html(data.subTitle);
    $('#concreteContent').html(data.content);
    $("#sonTitle").html(data.subTitle);
}
function flushO() {
    location.replace(location);
}